home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / amos / ldosv25d.lha / ldos_demo / examples / ldos / io-demo.AMOS / io-demo.amosSourceCode
AMOS Source Code  |  1992-01-02  |  2KB  |  56 lines

  1. 'This demo is rather slow since we only load 10 bytes at the time(!) 
  2. ' What it does is to open your startup-sequence, read 10 bytes, save 
  3. ' the 10 read bytes to a file called "ram:ut" (that is Swedish you know!)
  4. ' It repeats this until the SIZE read is less than 10 (we recahed the end
  5. ' of the file since less bytes than requested was returned). 
  6. '  
  7. ' The program then prints the position in both the files, and moves
  8. ' to the start of the written file "ram:ut" and overwrites the beginning 
  9. ' with the word "HELLO!" 
  10. '
  11. ' Then the whole file "ram:ut" is loaded and printed on the screen.
  12. '
  13. Screen Open 1,640,256,4,Hires
  14. Paper 0 : Clw 
  15.  Extension_10_0006 1,"s:startup-sequence",0
  16.  Extension_10_0006 2,"ram:ut",1
  17. Reserve As Work 10,10
  18. Repeat 
  19.    SIZE= Extension_10_0024(1,Start(10),10) : Rem Read 10 bytes. 
  20.    T= Extension_10_0034(2,Start(10),SIZE) : Rem Save read bytes to ram:ut
  21.    If T<>SIZE
  22.       Print "Diskerror!" : Extension_10_0016 1 : Extension_10_0016 2
  23.       End 
  24.    End If 
  25. Until SIZE<10 : Rem When size<10 we've read the last bytes 
  26. Print "Position in file 1"; Extension_10_0044(1,-1)
  27. Print "Position in file 2"; Extension_10_0044(2,-1)
  28. Print "Seeking to start of outputfile"
  29. Print "Position in outputfile is now"; Extension_10_0044(2,0)
  30. Print "Writing the word 'HELLO!' into start of outputfile"
  31. Centre "Press a Key" : Wait Key : Cline : Print : Cup 
  32. A$="Hello"
  33.  Extension_10_0084 A$,Start(10) : Rem Copy this string into bank 10
  34. T= Extension_10_0034(2,Start(10),Len(A$)) : Rem Saved the copied string
  35.  Extension_10_0016 1 : Rem IMPORTANT
  36.  Extension_10_0016 2 : Rem ALWAYS CLOSE 
  37.  Extension_10_0006 1,"ram:ut",0
  38. Erase 10
  39. ' Get size of the output file
  40. SIZE= Extension_10_0182("ram:ut")
  41. Reserve As Work 10,SIZE : Rem A bank with same size as our file
  42. T= Extension_10_0024(1,Start(10),SIZE) : Rem Load the whole file
  43. ST=Start(10)
  44. Repeat 
  45.    ' Get a line 
  46.    A$= Extension_10_006C(ST To Start(10)+SIZE)
  47.    ' Calc next startaddress which is A$+1 
  48.    ST=ST+Len(A$)+1 : Rem +1 for the linefeed
  49.    Print A$
  50.    Inc LI
  51.    If LI>20
  52.       Centre "Press a Key" : Print : Cup : Wait Key : Cline 
  53.       LI=0
  54.    End If 
  55. Until ST=>Start(10)+SIZE
  56.  Extension_10_0016 1